package com.neusoft.cloudstreamfeign.controller;

import com.neusoft.cloudstreamfeign.dto.Result;
import com.neusoft.cloudstreamfeign.dto.ServiceInfo;
import com.neusoft.cloudstreamfeign.dto.SiteInfo;
import com.neusoft.cloudstreamfeign.feign.SiteServiceClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.*;

/**
 * 站点服务Feign控制器
 * 通过负载均衡调用站点服务
 */
@RestController
@RequestMapping("/feign/site")
public class SiteFeignController {

    @Autowired
    @Qualifier("com.neusoft.cloudstreamfeign.feign.SiteServiceClient")
    private SiteServiceClient siteServiceClient;

    @GetMapping("/serviceInfo/list")
    public Result list(@RequestParam("pageNum") Integer pageNum, @RequestParam("pageSize") Integer pageSize,
                       @RequestParam(value = "siteId", required = false) Long siteId, @RequestParam(value = "serviceCode", required = false) String serviceCode) {
        return siteServiceClient.list(pageNum, pageSize, siteId, serviceCode);
    }
    @PostMapping( "/serviceInfo/create")
    public Result create(@RequestBody ServiceInfo serviceInfo) {
        return siteServiceClient.create(serviceInfo);
    }
    @PostMapping( "/serviceInfo/update")
    public Result update(@RequestBody ServiceInfo serviceInfo) {
        return siteServiceClient.update(serviceInfo);
    }
    @PostMapping("/serviceInfo/delete")
    public Result delete(@RequestBody ServiceInfo serviceInfo) {
        return siteServiceClient.delete(serviceInfo);
    }

    @GetMapping("/siteInfo/list")
    public Result list1(@RequestParam("pageNum") Integer pageNum, @RequestParam("pageSize") Integer pageSize,
                        @RequestParam(value = "siteCode", required = false) String siteCode) {
        return siteServiceClient.list1(pageNum, pageSize, siteCode);
    }
    @PostMapping("/siteInfo/create")
    public Result create1(@RequestBody SiteInfo siteInfo) {
        return siteServiceClient.create1(siteInfo);
    }
    @PostMapping("/siteInfo/update")
    public Result update1(@RequestBody SiteInfo siteInfo) {
        return siteServiceClient.update1(siteInfo);
    }
    @PostMapping("/siteInfo/delete")
    public Result delete1(@RequestBody ServiceInfo serviceInfo) {
        return siteServiceClient.delete1(serviceInfo);
    }


}
